package my.data.x.util;

import my.data.x.exception.XErrorCode;
import my.data.x.exception.XException;

public enum JobStatus {
    INIT("INIT"), RUNNING("RUNNING"), FAILD("FAILD"), SUCCESS("SUCCESS");
    private final String status;
    private JobStatus(String status) {
        this.status = status;
    }
    public static String getStatus(int statusTag){
        String statusStr;
        switch(statusTag){
            case 1: statusStr=JobStatus.INIT.status;break;
            case 2: statusStr=JobStatus.RUNNING.status;break;
            case 3:statusStr=JobStatus.FAILD.status;break;
            case 4:statusStr=JobStatus.SUCCESS.status;break;
            default: throw new XException(XErrorCode.RUNTION_ERROR,String.format("出现不存在的job状态，状态码是：%d",statusTag));
        }
        return statusStr;
    }

    public static int getStatusTag(JobStatus jobStatus){
        switch (jobStatus){
            case INIT:return 1;
            case RUNNING:return 2;
            case FAILD:return 3;
            case SUCCESS:return 4;
            default:return 0;

        }
    }


}
